var cardApp = new Framework7({
    //page切换动画
    animatePages: true,
    //模板自动编译
    precompileTemplates: true,
    //浏览器可以前进后退
    pushState: true,
    //使用JS滚动条（参见 iscroll),这样就不会不满屏幕就出现滚动条
    scroller:"js"
});

var $$ = Framework7.$;

var mainView = cardApp.addView('.view-main', {
  // Because we want to use dynamic navbar, we need to enable it for this view:
  dynamicNavbar: true
});

//统计页面statistics初始化回调加载eCharts图表
cardApp.onPageInit('statistics', function (page) {
    // 路径配置
    require.config({
        paths: {
            echarts: '../../../wechat/static/src/echarts-2.2.3/dist'
        }
    }); 
    //使用eCharts图表
    require(
        [
            'echarts',
            'echarts/chart/bar',  // 使用柱状图就加载bar模块，按需加载
            'echarts/chart/line', // 使用折线图就加载line模块，按需加载
        ],
        function (ec) {
            // 基于准备好的dom，初始化echarts图表
            var myChart = ec.init(document.getElementById('main')); 

            var option = {
                tooltip: {
                    show: true
                },
                toolbox: {
                    show : true,
                    feature : {
                        magicType : {show: true, type: ['line', 'bar']},
                        restore : {show: true}
                    }
                },
                legend: {
                    data:['销量']
                },
                xAxis : [
                    {
                        type : 'category',
                        data : ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
                    }
                ],
                yAxis : [
                    {
                        type : 'value'
                    }
                ],
                series : [
                    {
                        "name":"销量",
                        "type":"bar",
                        "data":[5, 20, 40, 10, 10, 20]
                    }
                ]
            };

            // 为echarts对象加载数据 
            myChart.setOption(option); 
        }
    );
});
